geom_point(data = subset(lgbtMM_UK, BY == "Heterosexual"),
aes(x = estimate, y = level), fill = "white", color = "grey67", size = 2.5, pch = 21) +
geom_label(data = subset(lgbtMM_UK, BY == "LGBTQ+"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = .4), size = 3, fontface = "bold"
) +
geom_label(data = subset(lgbtMM_UK, BY == "Heterosexual"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = -.2), size = 3, fontface = "bold"
)+
labs(y = NULL, subtitle = 'Conditional MM', x="")+
theme_ggdist() +
xlim(.1, .7)+
theme(legend.position = "none",
strip.background = element_blank(),
strip.text = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
plot.subtitle = element_text(face="bold", hjust=.5))
gen1+gen2
ggsave("figures_appendix/FigureA9.png", height=9, units="cm", dpi = 900)
###FIGURE A10###
lgbt_spain <- cj(tinder_conjoint_ES, selected ~ FLAG + BI + VEG + TRANS + CONGRUENCE + ETHNICITY + EMOTION + RELATIONSHIP + DISTANCE + EDUCATION_SLIM + JOB_SLIM + PARTY,
id = ~ ResponseId, estimate="amce",by = ~ queer)
lgbt_spain$lower90 <- lgbt_spain$estimate - (1.645 * lgbt_spain$std.error)
lgbt_spain$higher90 <- lgbt_spain$estimate + (1.645 * lgbt_spain$std.error)
lgbt_spain$lower95 <- lgbt_spain$estimate - (1.96 * lgbt_spain$std.error)
lgbt_spain$higher95 <- lgbt_spain$estimate + (1.96 * lgbt_spain$std.error)
lgbt_spain$lower99 <- lgbt_spain$estimate - (2.58 * lgbt_spain$std.error)
lgbt_spain$higher99 <- lgbt_spain$estimate + (2.58 * lgbt_spain$std.error)
lgbt_spain$lower999 <- lgbt_spain$estimate - (3.29 * lgbt_spain$std.error)
lgbt_spain$higher999 <- lgbt_spain$estimate + (3.29 * lgbt_spain$std.error)
lgbt_spain<-subset(lgbt_spain, feature %in% c("PARTY"))
gen1<- ggplot(lgbt_spain, aes(y = level, x = estimate, color = BY)) +
scale_shape_manual(values = c(10, 18)) +
scale_fill_manual(values = col2) +
scale_color_manual(values = col2) +
facet_grid(feature~., scales='free', space='free') +
geom_vline(xintercept = 0, colour="grey", linetype="dashed")+
geom_segment(data = subset(lgbt_spain, BY == "LGBTQ+"),
aes(x = lower90, xend = higher90, y = level, yend = level),
size = 4, alpha = 1,  position = position_nudge(y = .2)) +
geom_segment(data = subset(lgbt_spain, BY == "LGBTQ+"),
aes(x = lower95, xend = higher95, y = level, yend = level),
size = 3, alpha = .8,  position = position_nudge(y = .2)) +
geom_segment(data = subset(lgbt_spain, BY == "LGBTQ+"),
aes(x = lower99, xend = higher99, y = level, yend = level),
size = 2, alpha = .6, position = position_nudge(y = .2)) +
geom_point(data = subset(lgbt_spain, BY == "LGBTQ+"),
aes(x = estimate, y = level), fill = "white", color = "grey67", size = 2.5, pch = 21,
position = position_nudge(y = .2))+
geom_segment(data = subset(lgbt_spain, BY == "Heterosexual"),
aes(x = lower90, xend = higher90, y = level, yend = level),
size = 4, alpha = 1) +
geom_segment(data = subset(lgbt_spain, BY == "Heterosexual"),
aes(x = lower95, xend = higher95, y = level, yend = level),
size = 3, alpha = .8) +
geom_segment(data = subset(lgbt_spain, BY == "Heterosexual"),
aes(x = lower99, xend = higher99, y = level, yend = level),
size = 2, alpha = .6) +
geom_point(data = subset(lgbt_spain, BY == "Heterosexual"),
aes(x = estimate, y = level), fill = "white", color = "grey67", size = 2.5, pch = 21) +
geom_label(data = subset(lgbt_spain, BY == "LGBTQ+"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = .4), size = 3, fontface = "bold"
) +
geom_label(data = subset(lgbt_spain, BY == "Heterosexual"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = -.2), size = 3, fontface = "bold"
) +
annotate("label", x = -.15, y = 1.2, label = "Heterosexual",
color="black", size=3, fontface="bold", hjust=.5)+
annotate("label", x = -.15, y = 1, label = "LGBTQ+",
color="grey50", size=3, fontface="bold", hjust=.5)+
labs(y = NULL, subtitle = 'Conditional AMCE', x="")+
theme_ggdist() +
xlim(-.2,.5)+
theme(legend.position = "none",
strip.background = element_blank(),
strip.text = element_blank(),
plot.subtitle = element_text(face="bold", hjust=.5))
lgbtMM_spain <- cj(tinder_conjoint_ES, selected ~ FLAG + BI + VEG + TRANS + CONGRUENCE + ETHNICITY + EMOTION + RELATIONSHIP + DISTANCE + EDUCATION_SLIM + JOB_SLIM + PARTY,
id = ~ ResponseId, estimate="mm",by = ~ queer)
lgbtMM_spain$lower90 <- lgbtMM_spain$estimate - (1.645 * lgbtMM_spain$std.error)
lgbtMM_spain$higher90 <- lgbtMM_spain$estimate + (1.645 * lgbtMM_spain$std.error)
lgbtMM_spain$lower95 <- lgbtMM_spain$estimate - (1.96 * lgbtMM_spain$std.error)
lgbtMM_spain$higher95 <- lgbtMM_spain$estimate + (1.96 * lgbtMM_spain$std.error)
lgbtMM_spain$lower99 <- lgbtMM_spain$estimate - (2.58 * lgbtMM_spain$std.error)
lgbtMM_spain$higher99 <- lgbtMM_spain$estimate + (2.58 * lgbtMM_spain$std.error)
lgbtMM_spain$lower999 <- lgbtMM_spain$estimate - (3.29 * lgbtMM_spain$std.error)
lgbtMM_spain$higher999 <- lgbtMM_spain$estimate + (3.29 * lgbtMM_spain$std.error)
lgbtMM_spain<-subset(lgbtMM_spain, feature %in% c("PARTY"))
gen2<- ggplot(lgbtMM_spain, aes(y = level, x = estimate, color = BY)) +
scale_shape_manual(values = c(10, 18)) +
scale_fill_manual(values = col2) +
scale_color_manual(values = col2) +
facet_grid(feature~., scales='free', space='free') +
geom_segment(data = subset(lgbtMM_spain, BY == "LGBTQ+"),
aes(x = lower90, xend = higher90, y = level, yend = level),
size = 4, alpha = 1,  position = position_nudge(y = .2)) +
geom_segment(data = subset(lgbtMM_spain, BY == "LGBTQ+"),
aes(x = lower95, xend = higher95, y = level, yend = level),
size = 3, alpha = .8,  position = position_nudge(y = .2)) +
geom_segment(data = subset(lgbtMM_spain, BY == "LGBTQ+"),
aes(x = lower99, xend = higher99, y = level, yend = level),
size = 2, alpha = .6, position = position_nudge(y = .2)) +
geom_point(data = subset(lgbtMM_spain, BY == "LGBTQ+"),
aes(x = estimate, y = level), fill = "white", color = "grey67", size = 2.5, pch = 21,
position = position_nudge(y = .2))+
geom_segment(data = subset(lgbtMM_spain, BY == "Heterosexual"),
aes(x = lower90, xend = higher90, y = level, yend = level),
size = 4, alpha = 1) +
geom_segment(data = subset(lgbtMM_spain, BY == "Heterosexual"),
aes(x = lower95, xend = higher95, y = level, yend = level),
size = 3, alpha = .8) +
geom_segment(data = subset(lgbtMM_spain, BY == "Heterosexual"),
aes(x = lower99, xend = higher99, y = level, yend = level),
size = 2, alpha = .6) +
geom_point(data = subset(lgbtMM_spain, BY == "Heterosexual"),
aes(x = estimate, y = level), fill = "white", color = "grey67", size = 2.5, pch = 21) +
geom_label(data = subset(lgbtMM_spain, BY == "LGBTQ+"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = .4), size = 3, fontface = "bold"
) +
geom_label(data = subset(lgbtMM_spain, BY == "Heterosexual"),
aes(label = sprintf("%0.2f", round(estimate, digits = 2)), y = level, x = estimate),
position = position_nudge(y = -.2), size = 3, fontface = "bold"
)+
labs(y = NULL, subtitle = 'Conditional MM', x="")+
theme_ggdist() +
xlim(.1, .7)+
theme(legend.position = "none",
strip.background = element_blank(),
strip.text = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
plot.subtitle = element_text(face="bold", hjust=.5))
gen1+gen2
ggsave("figures_appendix/FigureA10.png", height=9, units="cm", dpi = 900)
###FIGURE A11###
EDEM <- read.dta13("data/E-DEM-Waves-Dataset.dta")
EDEM <- EDEM %>%
mutate(Party_New = ifelse(is.na(p30a_1), p31_1, p30a_1))
head(EDEM$p30a_1)
class(EDEM$Party_New)
EDEM_Rescaled <- EDEM
rescale <- function(x) {
(x - min(x, na.rm = TRUE)) / (max(x, na.rm = TRUE) - min(x, na.rm = TRUE))
}
vars_to_rescale <- c("p11r_2", "p11r_3", "p11r_4", "p11g_2", "p11g_3", "p11g_4")
for (var in vars_to_rescale) {
EDEM_Rescaled [[var]] <- rescale(EDEM_Rescaled [[var]])
}
EDEM_Rescaled$p11g_2N <- 1 - EDEM_Rescaled$p11g_2
EDEM_Rescaled$p11g_3N <- 1 - EDEM_Rescaled$p11g_3
EDEM_Rescaled$p11g_4N <- 1 - EDEM_Rescaled$p11g_4
ES_PP <- subset(EDEM_Rescaled, Party_New==1)
names(ES_PP)
meanVOX_W2 <- mean(ES_PP$p11r_2, na.rm = TRUE)
meanVOX_W3 <- mean(ES_PP$p11r_3, na.rm = TRUE)
meanVOX_W4 <- mean(ES_PP$p11r_4, na.rm = TRUE)
meanPSOE_W2 <- mean(ES_PP$p11g_2N, na.rm = TRUE)
meanPSOE_W3 <- mean(ES_PP$p11g_3N, na.rm = TRUE)
meanPSOE_W4 <- mean(ES_PP$p11g_4N, na.rm = TRUE)
ES_w2 <- ggplot(data = ES_PP) +
geom_density(aes(x = p11r_2, fill = "VOX"), alpha = 0.5, color = "green4") +
geom_density(aes(x = p11g_2N, fill = "PSOE"), alpha = 0.5, color = "red2") +
ylim(0,5)+
scale_fill_manual(values = c("red2", "green4"), labels=c("VOX", "PSOE")) +
scale_color_manual(values = c("red2", "green4")) +
labs(x="", subtitle = "a) Wave 2: (February 2019)") +
theme_ggdist() +
theme(legend.position = "none",
plot.subtitle = element_text(face = "bold"),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
annotate("text", x = 0, y = 3.55, label = "In-block love",
color = "green4", size = 4, fontface = "bold", hjust = 0) +
annotate("text", x = 0, y = 3.95, label = "Out-block hate",
color = "red3", size = 4, fontface = "bold", hjust = 0) +
geom_vline(xintercept = meanVOX_W2, linetype = "dashed", color = "green4") +
geom_vline(xintercept = meanPSOE_W2, linetype = "dashed", color = "red2")+
geom_label(aes(x = meanPSOE_W2, y = 4), nudge_x= .15,  label = round(meanPSOE_W2, 2),
color = "red2", vjust = -0.5)+
geom_label(aes(x = meanVOX_W2, y = 4), nudge_x= -.15,  label = round(meanVOX_W2, 2),
color = "green4", vjust = -0.5)
ES_w3 <- ggplot(data = ES_PP) +
geom_density(aes(x = p11r_3, fill = "VOX"), alpha = 0.5, color = "green4") +
geom_density(aes(x = p11g_3N, fill = "PSOE"), alpha = 0.5, color = "red2") +
ylim(0,5)+
scale_fill_manual(values = c("red2", "green4"), labels=c("VOX", "PSOE")) +
scale_color_manual(values = c("red2", "green4")) +
labs(x="", subtitle = "b) Wave 3: (Abril 2019)") +
theme_ggdist() +
theme(legend.position = "none",
plot.subtitle = element_text(face = "bold"),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
geom_vline(xintercept = meanVOX_W3, linetype = "dashed", color = "green4") +
geom_vline(xintercept = meanPSOE_W3, linetype = "dashed", color = "red2")+
geom_label(aes(x = meanPSOE_W3, y = 4), nudge_x= .15,  label = round(meanPSOE_W3, 2),
color = "red2", vjust = -0.5)+
geom_label(aes(x = meanVOX_W3, y = 4), nudge_x= -.15,  label = round(meanVOX_W3, 2),
color = "green4", vjust = -0.5)
ES_w4 <- ggplot(data = ES_PP) +
geom_density(aes(x = p11r_4, fill = "VOX"), alpha = 0.5, color = "green4") +
geom_density(aes(x = p11g_4N, fill = "PSOE"), alpha = 0.5, color = "red2") +
ylim(0,5)+
scale_fill_manual(values = c("red2", "green4"), labels=c("VOX", "PSOE")) +
scale_color_manual(values = c("red2", "green4")) +
labs(x="", subtitle = "c) Wave 4: (May 2019)") +
theme_ggdist() +
theme(legend.position = "none",
plot.subtitle = element_text(face = "bold"),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
geom_vline(xintercept = meanVOX_W4, linetype = "dashed", color = "green4") +
geom_vline(xintercept = meanPSOE_W4, linetype = "dashed", color = "red2")+
geom_label(aes(x = meanPSOE_W4, y = 4), nudge_x= .15,  label = round(meanPSOE_W4, 2),
color = "red2", vjust = -0.5)+
geom_label(aes(x = meanVOX_W4, y = 4), nudge_x= -.15,  label = round(meanVOX_W4, 2),
color = "green4", vjust = -0.5)
ES_PP$Dif_W2 <- ifelse(!is.na(ES_PP$p11r_2) & !is.na(ES_PP$p11g_2N), ES_PP$p11g_2N - ES_PP$p11r_2, NA)
ES_PP$Dif_W3 <- ifelse(!is.na(ES_PP$p11r_3) & !is.na(ES_PP$p11g_3N), ES_PP$p11g_3N - ES_PP$p11r_3, NA)
ES_PP$Dif_W4 <- ifelse(!is.na(ES_PP$p11r_4) & !is.na(ES_PP$p11g_4N), ES_PP$p11g_4N - ES_PP$p11r_4, NA)
Mean_Dif_W2 <- mean(ES_PP$Dif_W2, na.rm = TRUE)
Mean_Dif_W3 <- mean(ES_PP$Dif_W3, na.rm = TRUE)
Mean_Dif_W4 <- mean(ES_PP$Dif_W4, na.rm = TRUE)
ES_dif_w2 <- ggplot(data = ES_PP) +
geom_density(aes(x = Dif_W2, fill = "Difference"), alpha = 0.5, color = "cyan4") +
ylim(0,5)+
scale_fill_manual(values = c("cyan4"), labels=c("Differece")) +
scale_color_manual(values = c("cyan4")) +
labs(x="More in-block love – More out-block hate", subtitle = "") +
theme_ggdist() +
theme(legend.position = "none",
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
annotate("text", x = 0.1, y = 4, label = "Difference",
color = "cyan4", size = 4, fontface = "bold", hjust = 0) +
geom_vline(xintercept = Mean_Dif_W2, linetype = "dashed", color = "cyan4")+
geom_label(aes(x = Mean_Dif_W2, y = 4), nudge_x= .15,  label = round(Mean_Dif_W2, 2),
color = "cyan4", vjust = -0.5)
ES_dif_w3 <- ggplot(data = ES_PP) +
geom_density(aes(x = Dif_W3, fill = "Difference"), alpha = 0.5, color = "cyan4") +
ylim(0,5)+
scale_fill_manual(values = c("cyan4"), labels=c("Differece")) +
scale_color_manual(values = c("cyan4")) +
labs(x="More in-block love – More out-block hate", subtitle = "") +
theme_ggdist() +
theme(legend.position = "none",
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
geom_vline(xintercept = Mean_Dif_W3, linetype = "dashed", color = "cyan4") +
geom_label(aes(x = Mean_Dif_W3, y = 4), nudge_x= .15, label = round(Mean_Dif_W3, 2),
color = "cyan4", vjust = -0.5)
ES_dif_w4 <- ggplot(data = ES_PP) +
geom_density(aes(x = Dif_W4, fill = "Difference"), alpha = 0.5, color = "cyan4") +
ylim(0,5)+
scale_fill_manual(values = c("cyan4"), labels=c("Differece")) +
scale_color_manual(values = c("cyan4")) +
labs(x="More in-block love – More out-block hate", subtitle = "") +
theme_ggdist() +
theme(legend.position = "none",
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 10)) +
geom_vline(xintercept = Mean_Dif_W4, linetype = "dashed", color = "cyan4") +
geom_label(aes(x = Mean_Dif_W4, y = 4), nudge_x= .15, label = round(Mean_Dif_W4, 2),
color = "cyan4", vjust = -0.5)
EScombined_plot <- (ES_w2|ES_w3|ES_w4) / (ES_dif_w2 |ES_dif_w3| ES_dif_w4) +
plot_annotation(title = "Spain centre-right voters' in-block love & out-block hate",
subtitle = "Upper panel: Absolute affect for in-block & out-block partians\nLower panel: Difference negative out-block affect & positive in-bloc affect",
caption = "Source: E-Dem 2017-2020 Dataset") &
theme(plot.title = element_text(face="bold"))
ggsave("figures_appendix/FigureA11.png",dpi = 900)
###TABLE A7 and TABLE A8###
Spaindata <- Spaindata %>%
mutate(partyfull = case_when(
partyfull == 0 ~ "PSOE",
partyfull == 1 ~ "PP",
partyfull== 2 ~ "VOX",
partyfull == 3 ~ "Sumar",
partyfull == 4 ~ "Unidas Podemos",
partyfull == 5 ~ "Other",
partyfull == 6 ~ "Other",
partyfull == 7 ~ "Other",
partyfull == 8 ~ "Other",
partyfull == 9 ~ "Other",
TRUE ~ as.factor(partyfull)))
Spaindata <- Spaindata %>%
mutate(
educ = ifelse(educ == 9999, NA, educ),
degree = case_when(
educ < 4 ~ "No degree",
educ >= 4 ~ "Degree",
TRUE ~ NA_character_
),
degree = as.factor(degree)
)
Spaindata <- Spaindata %>%
mutate(sex = case_when(
sex == 0 ~ "Man",
sex == 1 ~ "Woman",
sex == 2 ~ "other",
sex == 3 ~ "other",
sex == 9999 ~ "other",
TRUE ~ as.factor(sex)))
Spaindata <- Spaindata %>%
mutate(sex_orient = case_when(
sex_orient == 0 ~ "Heterosexual",
sex_orient == 1 ~ "LGBTQ+",
sex_orient == 2 ~ "LGBTQ+",
sex_orient == 3 ~ "LGBTQ+",
sex_orient == 4 ~ "LGBTQ+",
sex_orient == 5 ~ "LGBTQ+",
sex_orient == 9999 ~ "LGBTQ+",
TRUE ~ as.factor(sex_orient)))
summ_spain <- Spaindata %>%
select(sex, age, degree, sex_orient, rile_self, partyfull)
datasummary_skim(summ_spain, type="categorical",  output='tables_appendix/TableA7.tex')
datasummary_skim(summ_spain, output='tables_appendix/TableA8.tex')
###TABLE A1 and TABLE A2###
directUK <- directUK |>
mutate(gender_bin= case_when(gender==2 ~ NA_real_,
TRUE ~ gender),
gender_bin= case_when(gender_bin== 1~1, gender_bin==0 ~ 2),
gender_text= case_when(gender== 0 ~ "Man",
gender== 1 ~ "Woman",
gender== 2 ~ "Non-binary"),
Education_text= case_when(degree== 1 ~ "Lower than university",
degree== 0 ~ "University degree or more"
)
) |>
drop_na(gender_bin, age, Education_text)
directUK <- directUK %>%
mutate(
sex_pref = case_when(
sex_pref == 1 ~ "men only",
sex_pref == 5 ~ "mainly men",
sex_pref == 6 ~ "mainly women",
sex_pref == 7 ~ "women only",
sex_pref == 3 ~ "both men and women equally"
),
tinder = case_when(
tinder == 1 ~ "Never used",
tinder == 2 ~ "A couple days",
tinder == 3 ~ "1-6 months",
tinder == 4 ~ "6 months-2 years",
tinder == 5 ~ "2-5 years",
tinder == 6 ~ ">5 years"
)
) |>
mutate(
sexual_identity = case_when(
gender_text == "Man" & sex_pref %in% c("men only") ~ "Gay",
gender_text == "Woman" & sex_pref %in% c("women only") ~ "Lesbian",
gender_text == "Woman" & sex_pref %in% c("both men and women equally", "mainly women", "mainly men") ~ "Bi woman",
gender_text == "Man" & sex_pref %in% c("both men and women equally", "mainly women", "mainly men")  ~ "Bi man",
gender_text == "Man" & sex_pref %in% c("women only") ~ "Man hetero",
gender_text == "Woman" & sex_pref %in% c("men only") ~ "Woman hetero",
TRUE ~ NA_character_  # For other cases or missing values
)
)
###TABLE A1 and TABLE A2###
directUK <- directUK |>
mutate(gender_bin= case_when(gender==2 ~ NA_real_,
TRUE ~ gender),
gender_bin= case_when(gender_bin== 1~1, gender_bin==0 ~ 2),
gender_text= case_when(gender== 0 ~ "Man",
gender== 1 ~ "Woman",
gender== 2 ~ "Non-binary"),
Education_text= case_when(degree== 1 ~ "Lower than university",
degree== 0 ~ "University degree or more"
)
) |>
drop_na(gender_bin, age, Education_text)
directUK <- directUK %>%
mutate(
sex_pref = case_when(
sex_pref == 1 ~ "men only",
sex_pref == 5 ~ "mainly men",
sex_pref == 6 ~ "mainly women",
sex_pref == 7 ~ "women only",
sex_pref == 3 ~ "both men and women equally"
),
tinder = case_when(
tinder == 1 ~ "Never used",
tinder == 2 ~ "A couple days",
tinder == 3 ~ "1-6 months",
tinder == 4 ~ "6 months-2 years",
tinder == 5 ~ "2-5 years",
tinder == 6 ~ ">5 years"
)
) |>
mutate(
sexual_identity = case_when(
gender_text == "Man" & sex_pref %in% c("men only") ~ "Gay",
gender_text == "Woman" & sex_pref %in% c("women only") ~ "Lesbian",
gender_text == "Woman" & sex_pref %in% c("both men and women equally", "mainly women", "mainly men") ~ "Bi woman",
gender_text == "Man" & sex_pref %in% c("both men and women equally", "mainly women", "mainly men")  ~ "Bi man",
gender_text == "Man" & sex_pref %in% c("women only") ~ "Man hetero",
gender_text == "Woman" & sex_pref %in% c("men only") ~ "Woman hetero",
TRUE ~ NA_character_  # For other cases or missing values
)
)
datasummary(gender_text + Education_text + sexual_identity + partyID_full + tinder + 1 ~ N + Percent(fn = function(x, y) 100 * length(x) / length(y)),
data = directUK, output="tables_appendix/TableA1.tex")
datasummary(age + ingroup_affect + outgroup_affect ~
Mean + SD + Min + Median + Max,
data = directUK,
fmt = "%.2f",
output = "tables_appendix/TableA2.tex")
datasummary(gender_text + Education_text + sexual_identity + partyID_full + tinder + 1 ~ N + Percent(fn = function(x, y) 100 * length(x) / length(y)),
data = directUK, output="tables_appendix/TableA1.tex")
datasummary(age + ingroup_affect + outgroup_affect ~
Mean + SD + Min + Median + Max,
data = directUK,
fmt = "%.2f",
output = "tables_appendix/TableA2.tex")
#---- Primary replication script ----
# Turnbull-Dugarte and López-Ortega (2025)
# "Radical Right Normalization & Centrifugal Affect. Evidence from the Dating Market"
# README: This single script will reproduce all analysis and output from the main text and supplementary appendix file,
# and produces three .html files of the log output from each.
remove(list=ls())
library(knitr)
library(sessioninfo)
rmarkdown::render("subscript1_datawrangling.R")
rmarkdown::render("subscript2_mainanalysis.R")
rmarkdown::render("subscript3_appendixmaterial.R")
summ_spain <- Spaindata %>%
select(sex, age, degree, sex_orient, rile_self, partyfull)
datasummary_skim(summ_spain, output='tables_appendix/TableA8.tex')
###TABLE A7 and TABLE A8###
Spaindata <- Spaindata %>%
mutate(partyfull = case_when(
partyfull == 0 ~ "PSOE",
partyfull == 1 ~ "PP",
partyfull== 2 ~ "VOX",
partyfull == 3 ~ "Sumar",
partyfull == 4 ~ "Unidas Podemos",
partyfull == 5 ~ "Other",
partyfull == 6 ~ "Other",
partyfull == 7 ~ "Other",
partyfull == 8 ~ "Other",
partyfull == 9 ~ "Other",
TRUE ~ as.factor(partyfull)))
Spaindata <- Spaindata %>%
mutate(
educ = ifelse(educ == 9999, NA, educ),
degree = case_when(
educ < 4 ~ "No degree",
educ >= 4 ~ "Degree",
TRUE ~ NA_character_
),
degree = as.factor(degree)
)
Spaindata <- Spaindata %>%
mutate(sex = case_when(
sex == 0 ~ "Man",
sex == 1 ~ "Woman",
sex == 2 ~ "other",
sex == 3 ~ "other",
sex == 9999 ~ "other",
TRUE ~ as.factor(sex)))
Spaindata <- Spaindata %>%
mutate(sex_orient = case_when(
sex_orient == 0 ~ "Heterosexual",
sex_orient == 1 ~ "LGBTQ+",
sex_orient == 2 ~ "LGBTQ+",
sex_orient == 3 ~ "LGBTQ+",
sex_orient == 4 ~ "LGBTQ+",
sex_orient == 5 ~ "LGBTQ+",
sex_orient == 9999 ~ "LGBTQ+",
TRUE ~ as.factor(sex_orient)))
summ_spain <- Spaindata %>%
select(sex, age, degree, sex_orient, rile_self, partyfull)
datasummary_skim(summ_spain, type="categorical",  output='tables_appendix/TableA7.tex')
datasummary_skim(summ_spain, output='tables_appendix/TableA8.tex')
datasummary_skim(summ_spain, type="categorical",  output='tables_appendix/TableA7.tex')
datasummary(gender_text + Education_text + sexual_identity + partyID_full + tinder + 1 ~ N + Percent(fn = function(x, y) 100 * length(x) / length(y)),
data = directUK, output="tables_appendix/TableA1.tex")
datasummary(gender_text + Education_text + sexual_identity + partyID_full + tinder + 1 ~ N + Percent,
data = directUK, output="tables_appendix/TableA1.tex")
#---- Primary replication script ----
# Turnbull-Dugarte and López-Ortega (2025)
# "Far Right Normalization & Centrifugal Affect. Evidence from the Dating Market"
# Conditionally accepted at 'Journal of Politics' (April 14th 2025)
# README: This single script will reproduce all analysis and output from the main text and supplementary appendix file,
# and produces three .html files of the log output from each.
remove(list=ls())
library(knitr)
library(sessioninfo)
rmarkdown::render("subscript1_datawrangling.R")
rmarkdown::render("subscript2_mainanalysis.R")
rmarkdown::render("subscript3_appendixmaterial.R")
writeLines(c(
"---- Session Info: Turnbull-Dugarte and López-Ortega (2025) ----",
capture.output(sessioninfo::session_info())
), "session_log.txt")
